<template>
  <div>
   
    <div v-for="menu in menus" :key="menu.path">
      <el-submenu
        v-if="menu.children && menu.children.length > 0"
        :index="menu.path"
        popper-append-to-body
      >
        <template slot="title">
          <i :class="menu.meta.icon"></i>
          <span>{{ menu.meta.title }}</span>
        </template>
        <!-- 嵌套使用组件 -->
        <navbar-item :menus="menu.children"></navbar-item>
      </el-submenu>
      <el-menu-item v-else :index="menu.path">
        <i :class="menu.meta.icon"></i>
        <span slot="title">{{ menu.meta.title }}</span>
      </el-menu-item>
    </div>
  </div>
</template>

<script>
export default {
  name: "NavbarItem",
  props: {
    menus: {
      type: Array,
      require: true,
    },
  },
};
</script>

<style scoped>
.el-menu--collapse span {
  display: none;
  
}
.el-menu--collapse .el-submenu__icon-arrow {
  display: none;
}

</style>